home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / hdsentry.zip / HDSENTRY.ASM < prev    next >
Assembly Source File  |  1987-05-23  |  6KB  |  142 lines

  1. ;   HARD DISK SENTRY -- FIXED DISK PROTECTION AGAINST TROJAN PROGRAMS
  2. ;                   Copyright 1987 by Andrew M. Fried
  3. ;
  4. ; HDSENTRY is the copyrighted property of its author. You are free to use
  5. ; this program without charge with my compliments. This program may freely
  6. ; be distributed so long as the following limitations are adhered to:
  7. ;   + No charge is made for its distribution
  8. ;   + The product is distributed in unmodified form
  9. ;   + The authors copyright notice is left in the program
  10. ;   + No portion of this program is included into any commercial package
  11. ;     without written consent of the author.
  12. ;
  13. ;
  14. ;  Andrew M. Fried
  15. ;  895 Cynthia Drive
  16. ;  Titusville, Fla.  32780
  17. ;  (305) 268-4500
  18. ;
  19. ;  [run program from hard or floppy; test newly uploaded programs from floppy.]
  20. ;  [listing printed in COMPUTER SHOPPER; June, 1987; page 228]
  21. ;----------------------------------------------------------------------------
  22.  
  23. page 60,132
  24. TITLE TITLE - HARD DISK SENTRY DISK PROTECTION UTILITY
  25.  
  26. cseg segment byte public
  27.  
  28. Public    maincode, go, copyright, alert_msg, old_13, old_26, install, tsr
  29. Public  sentry, which_disk, ok, abort, dummy, init, show_copr, get_int_13
  30. Public  set_int_13, set_int_26
  31.  
  32. maincode    proc far
  33.         assume    cs:cseg
  34.         org 100h        ;used to create a com program
  35.  
  36. go:             jmp  install
  37. copyright       db   13,10
  38.         db   '╔══════════════════════════════════════════════════╗',13,10
  39.         db   '║               HARD DISK SENTRY 1.01              ║',13,10
  40.         db   '║        (c) Copyright 1987 Andrew M. Fried        ║',13,10
  41.         db   '╚══════════════════════════════════════════════════╝',13,10
  42.         db   '         NO DESTRUCTIVE CALLS TO THE FIXED DISK',13,10
  43.         db   '                  WILL BE PERMITTED.',13,10,'$'
  44. alert_msg      db    13,10,07,'<<< ALERT >>>  Destructive disk call prevented!$'
  45. old_13         dd    0              ;address of original int 13h
  46. old_26         dd    0              ;address of original int 26h
  47. install:       call  init           ;initialize system
  48. tsr:           lea   dx,init        ;boundary of program
  49.            mov   cx,4           ;shift count used for division
  50.            shr   dx,cl          ;transform from bytes to paragraphs
  51.            inc   dx             ;add an extra paragraph for stragglers
  52.            mov   ax,3100h       ;terminate and stay resident dos call
  53.            int   21h            ;ask dos to terminare & stay resident
  54. maincode       endp
  55.  
  56.  
  57. ;--------------------------------------------------------------------
  58. ; This is the main guts of the program. Anytime a disk service is requested,
  59. ; this interrupt handler will be called. It acts much like a filter. Any
  60. ; calls involving the floppy disk are merely passed on to the fixed disk; however,
  61. ; it is checked. If the call is destructive (write or format), the handler
  62. ; prevents it from occuring. Simple but quite effective.
  63. ;--------------------------------------------------------------------
  64.  
  65. sentry      proc
  66. which_disk: cmp   dl,80h         ;are we working on the hard disk???
  67.         jb    ok             ;if not, simply continue on
  68.         cmp   ah,3           ;is it a write command?
  69.         je    abort          ;if so, abort
  70.         cmp   ah,5           ;is it a format command?
  71.         je    abort          ;if so, abort
  72.         cmp   ah,0Bh         ;is it an extended fd command??
  73.         je    abort          ;if so, abort
  74. ok:         jmp   dword ptr [old_13]      ;go back into original handler
  75. abort:      push  ax             ;save registers
  76.         push  dx
  77.         push  ds
  78.         mov   ah,9           ;dos print string function request
  79.         push  cs             ;insure ds = cs
  80.         pop   ds
  81.         lea   dx,alert_msg   ;require ds:dx string addressing
  82.         int   21h            ;call dos to print string
  83.         pop   ds             ;restore registers
  84.         pop   dx
  85.         pop   ax
  86.         sub   ah,ah          ;show no error code return
  87.         iret                 ;return to calling process
  88. sentry      endp
  89.  
  90. ;-----------------------------------------------------------------
  91. ; This procedure becomes the 'new' interrupt 26h handler. As you can see,
  92. ; when an application program makes this call, they don't get much chance to
  93. ; do any damage.
  94. ;-----------------------------------------------------------------
  95.  
  96. dummy       proc
  97.         sub   ax,ax          ;zero out the dx register
  98.         push  ax             ;place extra word on stack
  99.         iret                 ;return to caller with stack modified
  100. dummy       endp
  101.  
  102. ;---------------------------------------------------------------
  103. ; This procedure sets the interrupt vectors and displays the copyright notice
  104. ; (which I ask that you leave undisturbed).
  105. ;---------------------------------------------------------------
  106.  
  107. init        proc                       ;main initialization routine
  108. show_copr:  mov   ah,9                 ;dos print string function request
  109.         lea   dx,copyright         ;require ds:dx string addressing
  110.         int   21h                  ;call dos to print string
  111. get_int_13: mov   ax,3513h             ;get hard disk interrupt vector
  112.         int   21h                  ;use dos function call
  113.         mov   word ptr old_13,bx   ;store offset
  114.         mov   word ptr old_13[2],es   ;store segment
  115. set_int_13: mov   ax,2513h             ;make int 13 point to our handler
  116.         lea   dx,sentry            ;get address of interrupt routine
  117.         int   21h                  ;call dos to set new vector
  118. set_int_26: mov   ax,2526h             ;make int 26 point to our handler
  119.         lea   dx,dummy             ;get address of interrupt routine
  120.         int   21h                  ;call dos to set new vector
  121.         ret
  122. init        endp
  123. ;
  124. cseg        ends
  125.         end   go
  126.  
  127. ;
  128. ;====================================================================
  129. ; After very briefly testing HDSENTRY, some notes:
  130. ;   1) tested SuperKey and worked fine
  131. ;   2) then loaded Sidekick and attempted to save a file created in
  132. ;      notepad. DO NOT DO IT! Attemp to write on HD was interrupted
  133. ;      by program and had to hard boot the system.
  134. ;   3) loaded FlickerFree, then HDSENTRY, then word processor; attempt
  135. ;      to save dummy file to HD was interrupted but control returned
  136. ;      to DOS.
  137. ; Conclusion:
  138. ;  use HDSENTRY only for testing new downloaded or uploaded programs
  139. ;  ONLY. Do not have it resident when performing "normal" work.
  140. ;  Use floopy drive for testing.
  141. ;  D.L.Latkowski, 5/25/87
  142.